package zhongjie;

public class Lianjia implements HouseMediator {//链家，实现HouseMediator
    Purchaser mPurchaser;
    Landlord mLandlord;
    public void setPurchaser(Purchaser purchaser) {//设置买房者
        mPurchaser = purchaser;
    }//买房者类
    public void setLandlord(Landlord landlord) {//设置房东
        mLandlord = landlord;
    }//房东者类
    @Override
    public void notice(Person person, String message) {//发送通知
        System.out.println("中介收到信息，并转发给相应的目标人群");
        if (person == mPurchaser) {//如果是买房者类
            mLandlord.getNotice(message);//通知房东
        } else if (person == mLandlord) {//如果是房东
            mPurchaser.getNotice(message);//通知买房者
        }

    }
}
